﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using Terralever.Facebook.UI.Design;

namespace Terralever.Facebook.UI.FbmlControls
{
    /// <summary>
    /// Renders the content wrapped within the tag on an application canvas page if the user hasn't already added content to his or her 
    /// profile.
    /// </summary>
    /// <remarks>
    /// <para>The Facebook documentation for the rendered control can be found 
    /// <a href="http://wiki.developers.facebook.com/index.php/Fb:if-section-not-added" target="_blank">here</a>.</para>
    /// </remarks>
    public class IfSectionNotAdded : LogicTestControl
    {
        private ProfileSectionType m_sect = ProfileSectionType.Profile;
        /// <summary>
        /// Gets or sets the section to check.  This property is required.
        /// </summary>
        [Browsable(true)]
        [Category(FbmlConstants.FBML_REQD_ATTR)]
        [Description("Specifies which section to check.")]
        [DefaultValue(ProfileSectionType.Profile)]
        [FbmlRequired(IsRequired = true)]
        public ProfileSectionType Section
        {
            get { return m_sect; }
            set
            {
                if (!Enum.IsDefined(typeof(ProfileSectionType), value))
                    throw new InvalidEnumArgumentException("value", (int)value, typeof(ProfileSectionType));
                m_sect = value;
            }
        }

        /// <inheritdoc />
        protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);

            writer.AddAttribute("section", m_sect.ToString().ToLowerInvariant());
        }

        /// <inheritdoc />
        protected internal override string ElementName
        {
            get { return FbmlConstants.FB_IF_SECTION_NOT_ADDED; }
        }
    }
}
